<?php
namespace Swiftx\Interfaces\Router;

/**
 * 路由组件收集器
 *
 * @author		胡永强  <odaytudio@gmail.com>
 * @since		2015-10-09
 * @copyright	Copyright (c) 2014-2015 Swiftx Inc.
 * @default-implement Swiftx\Component\Router\Collection singleton=true
 */
interface Collection {

    /**
     * 注册一个路由器映射
     *
     * @param string $name
     * @param Dispatcher $dispatcher
     * @return mixed
     */
    public function registerDispatcher(string $name, Dispatcher $dispatcher);

    /**
     * 注解解析接口或类
     * @param string $value
     * @param string[] $evn
     */
    public function parseAnnotation(string $value, array $evn = []);

    /**
     * 执行路由分发
     * @param Request $request
     * @param Response $response
     * @return void
     */
    public function dispatch(Request $request, Response $response);

    /**
     * 获取路由器分发器
     * @param string $name
     * @return Dispatcher
     */
    public function getDispatcher(string $name, string $action):Dispatcher;

    /**
     * 获取所有路由器分发器
     * @return Dispatcher[]
     */
    public function getDispatchers():array ;

}